home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '90 / MacHack'90 Proceedings / John Norstad / Reusable Code / Source / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-10  |  19.2 KB  |  773 lines  |  [TEXT/MPS ]

  1. /*______________________________________________________________________
  2.  
  3.     main.c - Main Window Manager.
  4.     
  5.     Copyright © 1988, 1989, 1990 Northwestern University.  Permission is 
  6.     granted to use this code in your own projects, provided you give credit 
  7.     to both John Norstad and Northwestern University in your about box or 
  8.     document.
  9. _____________________________________________________________________*/
  10.  
  11.  
  12. #pragma load "precompile"
  13. #include "vol.h"
  14. #include "rep.h"
  15. #include "rpp.h"
  16. #include "scn.h"
  17. #include "utl.h"
  18. #include "rez.h"
  19. #include "glob.h"
  20. #include "wstm.h"
  21. #include "misc.h"
  22. #include "vscn.h"
  23. #include "vmsg.h"
  24. #include "prog.h"
  25. #include "help.h"
  26. #include "main.h"
  27. #include "unmount.h"
  28.  
  29. #pragma segment main
  30.  
  31. /*______________________________________________________________________
  32.  
  33.     Global Variables.
  34. _____________________________________________________________________*/
  35.  
  36.  
  37. static WindowPtr            MainWindow;            /* ptr to main window */
  38. static WindowRecord        MainWRecord;        /* main window record */
  39. static WindowObject        MainWindObject;    /* main window object */
  40.  
  41. static long                    DiskMessage;        /* disk insert message from
  42.                                                             event record */
  43. static Str255                WaitMsg;                /* disk insert wait message for
  44.                                                             display in window */
  45. static Rect                    WaitMsgRect;        /* disk insert wait message rect */
  46. static Handle                FloppyH;                /* handle to small floppy icon */
  47. static Boolean                FloppyBlack;        /* true if floppy wait, and blinking
  48.                                                             small icon is black */
  49.  
  50. /*______________________________________________________________________
  51.  
  52.     main_SetPort - Set the Current GrafPort to the Main Window.
  53. _____________________________________________________________________*/
  54.  
  55.  
  56. void main_SetPort (void)
  57.  
  58. {
  59.     SetPort(MainWindow);
  60. };
  61.  
  62. /*______________________________________________________________________
  63.  
  64.     main_DoScan - Do a Scan.
  65.     
  66.     Entry:    theMenu = menu number.
  67.                 theItem = item number in menu.
  68. _____________________________________________________________________*/
  69.  
  70.  
  71. void main_DoScan (short theMenu, short theItem)
  72.  
  73. {
  74.     short                    scanKind;            /* kind of scan */
  75.     short                    scanOp;                /* scanning operation */
  76.     
  77.     SetPort(MainWindow);
  78.     switch (theMenu) {
  79.         case scanMID:
  80.             scanOp = checkOp;
  81.             break;
  82.         case disinfectMID:
  83.             scanOp = disinfectOp;
  84.             break;
  85.     };
  86.     switch (theItem) {
  87.         case fileCommand:
  88.             scanKind = fileScan;
  89.             break;
  90.         case folderCommand:
  91.             scanKind = foldScan;
  92.             break;
  93.         case floppiesCommand:
  94.             scanKind = autoScan;
  95.             break;
  96.         case allDisksCommand:
  97.             scanKind = allScan;
  98.             break;
  99.         case someDisksCommand:
  100.             scanKind = volSetScan;
  101.             break;
  102.         case sysFileCommand:
  103.             scanKind = sysFileScan;
  104.             break;
  105.         case sysFolderCommand:
  106.             scanKind = sysFoldScan;
  107.             break;
  108.     };
  109.     vscn_DoScan(scanKind, scanOp);
  110. }
  111.  
  112. /*______________________________________________________________________
  113.  
  114.     main_WaitInsert - Wait for a Disk Insertion Event.
  115.     
  116.     Entry:    firstDisk = true if waiting for first disk.
  117.     
  118.     Exit:        *vRefNum = volume reference number of inserted disk.
  119.                 *canceled = true if canceled (Cancel button or cmd/.)
  120. _____________________________________________________________________*/
  121.  
  122.  
  123. void main_WaitInsert (Boolean firstDisk, short *vRefNum, 
  124.     Boolean *canceled)
  125.  
  126. {
  127.     long                lastTick;            /* tick count at last disk icon invert */
  128.     long                nowTick;                /* current tick count */
  129.     Rect                eraseRect;            /* rectangle to erase */                                                    
  130.     
  131.     SetPort(MainWindow);
  132.     FloppyWait = true;
  133.     FloppyBlack = false;
  134.     misc_SetCursor();
  135.     lastTick = TickCount();
  136.     FloppyH = GetResource('SICN', floppyIconID);
  137.     eraseRect = WaitMsgRect = RectList[volNameRect];
  138.     InsetRect(&eraseRect, -2, -2);
  139.     eraseRect.right += 500;
  140.     EraseRect(&eraseRect);
  141.     WaitMsgRect.right += 500;
  142.     GetIndString(WaitMsg, strListID, firstDisk ? firstDiskStr : nextDiskStr);
  143.     InvalRect(&eraseRect);
  144.     InvalRect(&RectList[volIconRect]);
  145.     while (FloppyWait) {
  146.         if (InForeground) {
  147.             nowTick = TickCount();
  148.             if (nowTick >= lastTick + invertInterval) {
  149.                 lastTick = nowTick;
  150.                 InvertRect(&RectList[volIconRect]);
  151.                 FloppyBlack = !FloppyBlack;
  152.             };
  153.         };
  154.         prog_Event();
  155.         if (!FloppyWait && !Canceled) {
  156.             FloppyWait = utl_DoDiskInsert(DiskMessage, vRefNum);
  157.         };
  158.     };
  159.     *canceled = Canceled;
  160.     InvalRect(&eraseRect);
  161.     InvalRect(&RectList[volIconRect]);
  162.     misc_SetCursor();
  163. }
  164.  
  165. /*______________________________________________________________________
  166.  
  167.     Update - Process an Update Event.
  168. _____________________________________________________________________*/
  169.  
  170.  
  171. static void Update (void)
  172.  
  173. {
  174.     Handle                iconHandle;        /* handle to icon */
  175.     short                    oldFont;            /* saved font number */
  176.     short                    oldSize;            /* saved font size */
  177.     short                    baseLine;        /* baseline for counter */
  178.     short                    right;            /* right coord of counter title */
  179.     Str255                str;                /* multi-purpose string */
  180.     
  181.     SetPort(MainWindow);
  182.     
  183.     /*    Draw the controls. */
  184.     
  185.     DrawControls(MainWindow);
  186.     
  187.     /* Draw the small volume icon and the volume name in the
  188.         system font and size. */
  189.     
  190.     oldFont = qd.thePort->txFont;
  191.     oldSize = qd.thePort->txSize;
  192.     TextFont(systemFont);
  193.     TextSize(0);
  194.     if (FloppyWait) {
  195.         utl_PlotSmallIcon(&RectList[volIconRect], FloppyH);
  196.         if (FloppyBlack) InvertRect(&RectList[volIconRect]);
  197.         TextBox(WaitMsg+1, *WaitMsg, &WaitMsgRect, teJustLeft);
  198.     } else {
  199.         vol_DoUpdate();
  200.     };
  201.     TextFont(oldFont); 
  202.     TextSize(oldSize);
  203.     
  204.     /*    Draw the small folder and file icons. */
  205.     
  206.     iconHandle = GetResource('SICN', folderIconID);
  207.     utl_PlotSmallIcon(&RectList[foldIconRect], iconHandle);
  208.     iconHandle = GetResource('SICN', fileIconID);
  209.     utl_PlotSmallIcon(&RectList[fileIconRect], iconHandle);
  210.     
  211.     /* Draw the counters. */
  212.     
  213.     baseLine = RectList[counterRect].top + 12;
  214.     right = RectList[counterRect].right;
  215.     GetIndString(str, strListID, counter1);
  216.     MoveTo(right - StringWidth(str), baseLine);
  217.     DrawString(str);
  218.     NumToString(NumScanned, str);
  219.     MoveTo(right+5, baseLine);
  220.     DrawString(str);
  221.     baseLine += 12;
  222.     GetIndString(str, strListID, counter2);
  223.     MoveTo(right - StringWidth(str), baseLine);
  224.     DrawString(str);
  225.     NumToString(NumInfected, str);
  226.     MoveTo(right+5, baseLine);
  227.     DrawString(str);
  228.     baseLine += 12;
  229.     GetIndString(str, strListID, counter3);
  230.     MoveTo(right - StringWidth(str), baseLine);
  231.     DrawString(str);
  232.     NumToString(NumErrors, str);
  233.     MoveTo(right+5, baseLine);
  234.     DrawString(str);
  235.         
  236.     /*    Update the folder and file names and the thermometer rectangle. */
  237.     
  238.     scn_Update(&RectList[thermRect]);
  239.     
  240.     /*    Draw the report. */
  241.     
  242.     rep_Update(Report);
  243.     
  244.     /* Draw the grow icon. */
  245.     
  246.     utl_DrawGrowIcon(MainWindow);
  247. }
  248.     
  249. /*______________________________________________________________________
  250.  
  251.     Activate - Process an Activate Event.
  252. _____________________________________________________________________*/
  253.  
  254.  
  255. static void Activate (void)
  256.  
  257. {
  258.     rep_Activate(Report, true);
  259.     utl_DrawGrowIcon(MainWindow);
  260.     if (!Scanning) vol_Verify();
  261.     misc_SetCursor();
  262. }
  263.     
  264. /*______________________________________________________________________
  265.  
  266.     Deactivate - Process a Deactivate Event.
  267. _____________________________________________________________________*/
  268.  
  269.  
  270. static void Deactivate (void)
  271.  
  272. {
  273.     rep_Activate(Report, false);
  274.     utl_DrawGrowIcon(MainWindow);
  275.     misc_SetCursor();
  276. }
  277.  
  278. /*______________________________________________________________________
  279.  
  280.     Click - Process Mouse Down Event.
  281.     
  282.     Entry:        where = mouse down location, local coords.
  283.                     modifiers = modifier keys.
  284. _____________________________________________________________________*/
  285.  
  286.  
  287. static void Click (Point where, short modifiers)
  288.  
  289. {
  290.     ControlHandle        whichControl;    /* handle to selected control */
  291.     short                    vRefNum;            /* ref num of vol to be ejected */
  292.     Rect                    repRect;            /* report rectangle */
  293.     
  294.     /* Check for and process mouse down in report rectangle scroll bar. */
  295.     
  296.     rep_GetRect(Report, &repRect);
  297.     if (PtInRect(where, &repRect)) {
  298.         rep_Scroll(Report, where);
  299.         return;
  300.     };
  301.     
  302.     /* Check for and process mouse down in the volume name rectangle. */
  303.     
  304.     if (!Scanning) {
  305.         (void) vol_DoPopUp(where, mainPopUpID);
  306.         misc_HiliteScan();
  307.     };
  308.     
  309.     /* Check for and process mouse down in a control. */
  310.     
  311.     (void) FindControl(where, MainWindow, &whichControl);
  312.     if (whichControl != nil) {
  313.         if (TrackControl(whichControl, where, nil)) {
  314.             switch ((**whichControl).contrlRfCon) {
  315.                 case driveID:
  316.                     vol_DoDrive();
  317.                     break;
  318.                 case ejectID:
  319.                     if (!vol_GetSel(&vRefNum)) {
  320.                         misc_CheckEject(vRefNum);
  321.                         vol_DoEject();
  322.                     };
  323.                     misc_HiliteScan();
  324.                     break;
  325.                 case scanID:
  326.                     vscn_DoButton(checkOp, modifiers);
  327.                     break;
  328.                 case disinfectID:
  329.                     vscn_DoButton(disinfectOp, modifiers);
  330.                     break;
  331.                 case cancelID:
  332.                     Canceled = true;
  333.                     Scanning = FloppyWait = false;
  334.                     break;
  335.                 case quitID:
  336.                     Done = true;
  337.                     break;
  338.                 case resetID:
  339.                     vmsg_ClearCounters( RectList[counterRect].top,
  340.                         RectList[counterRect].right);
  341.                     break;
  342.             };
  343.         };
  344.     };
  345. }
  346.  
  347. /*______________________________________________________________________
  348.  
  349.     Help - Process Mouse Down Event in Help Mode.
  350.     
  351.     Entry:        where = mouse down location, local coords.
  352. _____________________________________________________________________*/
  353.  
  354.  
  355. static void Help (Point where)
  356.  
  357. {
  358.     short                reportLineNum;    /* line number of selected report line */
  359.     short                tag;                /* tag to jump to in help window */
  360.     short                i;                    /* loop index */
  361.     Rect                repRect;            /* report rectangle */
  362.     
  363.     rep_GetRect(Report, &repRect);
  364.     if (PtInRect(where, &repRect)) { 
  365.     
  366.         /* Report rectangle. */
  367.         
  368.         if (where.h >= repRect.right-16) {
  369.             help_Open(tagReport);
  370.         } else {
  371.             reportLineNum = rep_Click(Report, where);
  372.             if (reportLineNum >= 0) {
  373.                 tag = vmsg_LookupTag(reportLineNum);
  374.                 if (tag > 0) {
  375.                     help_Open(tag);
  376.                 } else {
  377.                     help_Open(tagReport);
  378.                 };
  379.             } else {
  380.                 help_Open(tagReport);
  381.             };
  382.         };
  383.         
  384.     } else if (where.v <= RectList[counterRect].top + 36 &&
  385.         where.h >= RectList[thermRect].left) {
  386.     
  387.         /* Upper right corner of the window. */
  388.         
  389.         help_Open(tagUpperRight);
  390.         
  391.     } else {
  392.     
  393.         /* Check for mouse down in a button. */
  394.     
  395.         for (i = 0; i < numControls; i++) {
  396.             if (PtInRect(where, &(**Controls[i]).contrlRect)) break;
  397.         };
  398.         if (i < numControls) {
  399.             help_Open(tagFirstButton+i);
  400.         } else {
  401.             help_Open(tagMainWind);
  402.         };
  403.     
  404.     };
  405. }
  406.  
  407. /*______________________________________________________________________
  408.  
  409.     ChangeSize - Process Window Size Change.
  410.     
  411.     Entry:    height = new window height.
  412. _____________________________________________________________________*/
  413.  
  414.  
  415. static void ChangeSize (short height)
  416.  
  417. {
  418.     rep_Height(Report, height - 6);
  419.     if (Scanning) rep_Jump(Report, rep_GetSize(Report), true);
  420. }
  421.  
  422. /*______________________________________________________________________
  423.  
  424.     Grow - Process Window Grow Operation.
  425.     
  426.     Entry:    height = new window height.
  427.                 width = new window width.
  428. _____________________________________________________________________*/
  429.  
  430.  
  431. static void Grow (short height, short width)
  432.  
  433. {
  434.     utl_InvalGrow(MainWindow);
  435.     SizeWindow(MainWindow, width, height, true);
  436.     utl_InvalGrow(MainWindow);
  437.     ChangeSize(height);
  438. }
  439.     
  440. /*______________________________________________________________________
  441.  
  442.     Zoom - Process Window Zoom Operation.
  443. _____________________________________________________________________*/
  444.  
  445.  
  446. static void Zoom (void)
  447.  
  448. {
  449.     ChangeSize(MainWindow->portRect.bottom - MainWindow->portRect.top);
  450. }
  451.     
  452. /*______________________________________________________________________
  453.  
  454.     Key - Process Key Down Event.
  455.     
  456.     Entry:    key = ascii code of key pressed.
  457.                 modifiers = modifier keys.
  458. _____________________________________________________________________*/
  459.  
  460.  
  461. static void Key (short key, short modifiers)
  462.  
  463. {
  464.     if (Scanning) return;
  465.     if (key == upArrow || key == downArrow) {
  466.         rep_Key(Report, key, modifiers);
  467.     } else if (key == tabKey && 
  468.         !(**Controls[driveID-firstControl]).contrlHilite) {
  469.         vol_DoDrive();
  470.         misc_HiliteScan();
  471.     };
  472. }
  473.     
  474. /*______________________________________________________________________
  475.  
  476.     Close - Close the Window.
  477. _____________________________________________________________________*/
  478.  
  479.  
  480. static void Close (void)
  481.  
  482. {
  483.     Prefs.mainState.moved = MainWindObject.moved;
  484.     wstm_Save(MainWindow, &Prefs.mainState);
  485.     CloseWindow(MainWindow);
  486.     MainWindow = nil;
  487. };
  488.     
  489. /*______________________________________________________________________
  490.  
  491.     main_Disk - Process Disk Insertion Event.
  492.     
  493.     Entry:    message = message field from event record.
  494. _____________________________________________________________________*/
  495.  
  496.  
  497. void main_Disk (long message)
  498.  
  499. {
  500.     SetPort(MainWindow);
  501.     if (FloppyWait) {
  502.         DiskMessage = message;
  503.         FloppyWait = false;
  504.         return;
  505.     } else if (!Scanning) {
  506.         SetPort(MainWindow);
  507.         (void) vol_DoInsert(message);
  508.         misc_HiliteScan();
  509.     };
  510. }
  511.     
  512. /*______________________________________________________________________
  513.  
  514.     main_Save - Process Save Command.
  515.     
  516.     Exit:        function result = true if file saved, false if canceled.
  517. _____________________________________________________________________*/
  518.  
  519.  
  520. Boolean main_Save (void)
  521.  
  522. {
  523.     Str255            prompt;            /* SFPutFile prompt string */
  524.     Boolean            good;                /* true if report saved, false if
  525.                                                 canceled by user */
  526.     OSErr                rCode;            /* result code */
  527.     Str255            rCodeStr;        /* result code as a string */
  528.     long                savedTrapAddr;    /* saved UnmountVol trap address */
  529.     
  530.     /* Get the prompt string. */
  531.     
  532.     GetIndString(prompt, strListID, putPromptStr);
  533.     
  534.     /* If scanning, patch the UnmountVol trap to prevent volume unmounting. */
  535.     
  536.     if (Scanning) {
  537.         
  538.         /* Patch the UnmountVol trap to prevent volumn unmounting. */
  539.         
  540.         savedTrapAddr = NGetTrapAddress(_UnmountVol, ToolTrap);
  541.         NSetTrapAddress((long)UNMOUNT, _UnmountVol, ToolTrap);
  542.     };
  543.     
  544.     /* Call rep_Save to save the file. */
  545.     
  546.     rCode = rep_Save(Report, prompt, "", Prefs.repCreator, &good, MenuPick);
  547.     
  548.     /* Handle errors. */
  549.     
  550.     if (rCode) {
  551.         if (rCode == dskFulErr) {
  552.             (void) utl_StopAlert(diskFullID, nil, 0);
  553.         } else {
  554.             NumToString(rCode, rCodeStr);
  555.             ParamText(rCodeStr, nil, nil, nil);
  556.             utl_StopAlert(unexpectedSaveID, nil, 0);
  557.         };
  558.     };
  559.     
  560.     /* If scanning, restore the UnmountVol trap. */
  561.     
  562.     if (Scanning) {
  563.         NSetTrapAddress(savedTrapAddr, _UnmountVol, ToolTrap);
  564.     } else {
  565.         main_SetPort();
  566.         vol_Verify();
  567.         misc_HiliteScan();
  568.     };
  569.  
  570.     return good;
  571. }
  572.     
  573. /*______________________________________________________________________
  574.  
  575.     PageSetup - Process Page Setup Command.
  576. _____________________________________________________________________*/
  577.  
  578. static void PageSetup (void)
  579.  
  580. {
  581.     misc_ValPrint(&Prefs.mainPrint, true);
  582.     Prefs.mainPrint.menuPick = MenuPick;
  583.     rpp_StlDlog(&Prefs.mainPrint);
  584. }
  585.     
  586. /*______________________________________________________________________
  587.  
  588.     Print - Process Print Command.
  589.     
  590.     Entry:    printOne = true if Print One command.
  591.     
  592.     Exit:        function result = error code.
  593. _____________________________________________________________________*/
  594.  
  595.  
  596. static OSErr Print (Boolean printOne)
  597.  
  598. {
  599.     Str255            titleTmpl;    /* template for date, time, pnum in headers */
  600.     Str255            docName;        /* document name */
  601.     
  602.     GetIndString(titleTmpl, strListID, prRepTmpl);
  603.     GetIndString(docName, strListID, prRepTitle);
  604.     Prefs.mainPrint.title = docName;
  605.     Prefs.mainPrint.titleTmpl = titleTmpl;
  606.     Prefs.mainPrint.docName = docName;
  607.     misc_ValPrint(&Prefs.mainPrint, true);
  608.     Prefs.mainPrint.menuPick = MenuPick;
  609.     return rpp_Print(Report, printOne, &Prefs.mainPrint);
  610.         
  611. }
  612.     
  613. /*______________________________________________________________________
  614.  
  615.     Edit - Process Edit Command.
  616.     
  617.     Entry:    cmd = which Edit command.
  618. _____________________________________________________________________*/
  619.  
  620.  
  621. static void Edit (EditCmd cmd)
  622.  
  623. {
  624.     Boolean            clear;            /* true to clear report */
  625.  
  626.     if (cmd != clearCmd) return;
  627.     clear = true;
  628.     if (RepInfected) {
  629.         switch (utl_StopAlert(saveRepID2, nil, 3)) {
  630.             case 1: /* Yes */
  631.                 clear = main_Save();
  632.                 break;
  633.             case 2: /* No */
  634.                 break;
  635.             case 3: /* Cancel */
  636.                 clear = false;
  637.                 break;
  638.         };
  639.     };
  640.     if (clear) misc_ClearReport();
  641. }    
  642.     
  643. /*______________________________________________________________________
  644.  
  645.     Adjust - Adjust Menus.
  646. _____________________________________________________________________*/
  647.  
  648.  
  649. static void Adjust (void)
  650.  
  651. {
  652.     MenuHandle                fileM;                    /* handle to file menu */
  653.     MenuHandle                editM;                    /* handle to edit menu */
  654.     MenuHandle                scanM;                    /* handle to scan menu */
  655.     MenuHandle                disinfectM;                /* handle to disinfect menu */
  656.     
  657.     fileM = GetMHandle(fileMID);
  658.     editM = GetMHandle(editMID);
  659.     scanM = GetMHandle(scanMID);
  660.     disinfectM = GetMHandle(disinfectMID);
  661.     DisableItem(fileM, closeCommand);
  662.     if (Scanning) {
  663.         DisableItem(fileM, saveAsCommand);
  664.         DisableItem(fileM, pageSetupCommand);
  665.         DisableItem(fileM, printCommand);
  666.         DisableItem(fileM, printOneCommand);
  667.         DisableItem(fileM, quitCommand);
  668.         DisableItem(editM, 0);
  669.         DisableItem(scanM, 0);
  670.         DisableItem(disinfectM, 0);
  671.     } else {
  672.         EnableItem(fileM, saveAsCommand);
  673.         EnableItem(fileM, pageSetupCommand);
  674.         EnableItem(fileM, printCommand);
  675.         EnableItem(fileM, printOneCommand);
  676.         EnableItem(fileM, quitCommand);
  677.         DisableItem(editM, undoCommand);
  678.         DisableItem(editM, cutCommand);
  679.         DisableItem(editM, copyCommand);
  680.         DisableItem(editM, pasteCommand);
  681.         EnableItem(editM, clearCommand);
  682.         EnableItem(editM, 0);
  683.         EnableItem(scanM, 0);
  684.         EnableItem(disinfectM, 0);
  685.     };
  686. }
  687.     
  688. /*______________________________________________________________________
  689.  
  690.     main_Open - Open Main Window.
  691. _____________________________________________________________________*/
  692.  
  693.  
  694. void main_Open (void)
  695.  
  696. {
  697.     Handle            floppyH;                /* handle to small floppy icon */
  698.     Handle            hardH;                /* handle to small hard drive icon */
  699.     short                i;                        /* loop index */
  700.     short                fNum;                    /* font number */
  701.     
  702.     /* Get the main window and restore its state. */
  703.     
  704.     MainWindow = wstm_Restore(false, mainWindID, (Ptr)&MainWRecord,
  705.         &Prefs.mainState);
  706.     SetPort(MainWindow);
  707.     
  708.     /* Initialize the window object. */
  709.     
  710.     ((WindowPeek)MainWindow)->refCon = (long)&MainWindObject;
  711.     MainWindObject.windKind = mainWind;
  712.     MainWindObject.moved = Prefs.mainState.moved;
  713.     SetRect(&MainWindObject.sizeRect, MainWindow->portRect.right, 
  714.         minMainSize, MainWindow->portRect.right, 0x7fff);
  715.     MainWindObject.update = Update;
  716.     MainWindObject.activate = Activate;
  717.     MainWindObject.deactivate = Deactivate;
  718.     MainWindObject.click = Click;
  719.     MainWindObject.help = Help;
  720.     MainWindObject.grow = Grow;
  721.     MainWindObject.zoom = Zoom;
  722.     MainWindObject.key = Key;
  723.     MainWindObject.close = Close;
  724.     MainWindObject.disk = main_Disk;
  725.     MainWindObject.save = main_Save;
  726.     MainWindObject.pageSetup = PageSetup;
  727.     MainWindObject.print = Print;
  728.     MainWindObject.edit = Edit;
  729.     MainWindObject.adjust = Adjust;
  730.     MainWindObject.periodic = nil;
  731.     MainWindObject.dialogPre = nil;
  732.     MainWindObject.dialogPost = nil;
  733.     
  734.     /*    Get the window controls.
  735.         Inactivate the cancel button. */
  736.     
  737.     for (i=0; i<numControls; i++) {
  738.         Controls[i] = utl_GetNewControl(firstControl+i, MainWindow);
  739.     };
  740.     HiliteControl(Controls[cancelID-firstControl], 255);
  741.     
  742.     /* Set the window's font to Geneva 9.  If Geneva doesn't exist
  743.         use the application font.  This is the font that will be used in
  744.         the report window. */
  745.     
  746.     if (!utl_GetFontNumber("\pGeneva", &fNum)) fNum = applFont;
  747.     TextFont(fNum);
  748.     TextSize(9);
  749.     
  750.     /* Initialize the volume selection module. */
  751.     
  752.     floppyH = GetResource('SICN', floppyIconID);
  753.     hardH = GetResource('SICN', hardDriveIconID);
  754.     (void) vol_Init( 
  755.         Controls[driveID-firstControl],
  756.         Controls[ejectID-firstControl],
  757.         &RectList[volNameRect],
  758.         &RectList[volIconRect],
  759.         floppyH,
  760.         hardH,
  761.         true,
  762.         true);
  763.         
  764.     /* Initialize the report. */
  765.     
  766.     rep_Init(&RectList[reportRect], MainWindow, 0, 0, 0, 0, &Report);
  767.     rep_Height(Report, MainWindow->portRect.bottom - 6);
  768.     rep_Fill(Report, repHeadID, false);
  769.     
  770.     /* Show the main window. */
  771.     
  772.     ShowWindow(MainWindow);
  773. }